home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
9-Digit Zip Code Directory
/
9-Digit Zip Code Directory (American Business Information) (ABIZIP-12).ISO
/
z4src.zip
/
BSCRISEC.C
< prev
next >
Wrap
C/C++ Source or Header
|
1993-05-31
|
3KB
|
100 lines
//----------------------------------------------------------------------------
// MODULE DESCRIPTION
//
// Module: bscrisec.c
// Title: Base library
// Notice: John M. Weeder
// Copyright (c) 1993. All rights reserved.
// This module contains proprietary information and should be
// treated as confidential.
//
//----------------------------------------------------------------------------
// MAINTENANCE HISTORY
//
// $Workfile$
// $Revision$
// $Author$
// $Date$
// $Log$
//
//----------------------------------------------------------------------------
// MODULE NARRATIVE
//
//
// This module contains contains code to manage critical sections under OS/2.
// This code is not useful under other OS's but the functions are still used
// for portability reasons.
//
// The code in this module should be written entirely in C.
// Do not use any C++ constructs.
//
// This module is portable to:
// DOS 3.X+
// MS Windows 3.X+
// OS/2 2.X+
// OS/2 2.0 PM
// SCO UNIX.
//
// The following compilers are supported:
// MSC 6.0A
// MSC/C++ 7.0
// Borland C++ 3.1 for DOS
// Borland C++ 1.0 for OS/2 2.X
// SCO UNIX cc
//
//----------------------------------------------------------------------------
#include <bs.h>
//----------------------------------------------------------------------------
// Globals
//----------------------------------------------------------------------------
static ULONG ulCritCount = 0;
//----------------------------------------------------------------------------
// Description: Enter critical section code
// Not applicatable to DOS mode, although it could be used
// to prevent critical section conflict amoung interrupt
// handlers.
// Parameters:
// Returns: TRUE if successful.
//----------------------------------------------------------------------------
VOID FN_E CritSecEnter(void)
{
#if OS_OS2 || OS_PM
DosEnterCritSec();
#endif
ulCritCount++; // Initial count
if (ulCritCount == MAX_ULONG) // Increment count
{
Halt("Critical section counter overflow.");
return ;
}
return ;
}
//----------------------------------------------------------------------------
// Description: Exit critical section code
// Parameters: None
// Returns: void
//----------------------------------------------------------------------------
VOID FN_E CritSecExit(void)
{
if (!ulCritCount)
{
Halt("Critical section counter underflow.");
return ;
}
ulCritCount--; // Decrement count
#if OS_OS2 || OS_PM
DosExitCritSec();
#endif
return ;
}
//----------------------------------------------------------------------------
//------------------------------- End of File --------------------------------
//----------------------------------------------------------------------------